<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
        <title>课程信息管理</title>
        <include file='Layout:ins_css' />
        <style type="text/css">
            .file-footer-buttons .kv-file-upload {
                display: none;
            }

            .file-footer-buttons .kv-file-zoom {
                display: none;
            }
            .file-footer-buttons .kv-file-remove {
                display: none;
            }
            .file-drop-zone-title {
                color: rgb(170, 170, 170);
                font-size: 1.3em;
                cursor: default;
                padding: 51px 10px;
            }

            #addBtn {
                float: right;
                margin: -7px -6px 9px;
            }
            .price-div {
                /*float: left;*/
                margin: 12px 0px 6px 16px;
            }

            .price-div input {
                width: 60%;
                float: left;
                margin-right: 6px;
            }

            .price-div p {
                line-height: 25px;
                margin-right: 6px;
                float: left;
            }

            .price-div select {
                /*float: left;*/
                width: 60%;
                margin-right: 10px;

            }
            .cyf-form-group{
                margin-top: 10px;
                margin-bottom: 10px;

            }
            .cyf-label{
                padding: 3px 0 0 0;
            }
            .select2-drop {
                z-index: 10050 !important;
            }

            .select2-search-choice-close {
                margin-top: 0 !important;
                right: 2px !important;
                min-height: 10px;
            }
            .select2-search-choice-close:before {
                color: black !important;
            }
            /*防止select2不会自动失去焦点*/

            .select2-container {
                z-index: 16000 !important;
            }

            .select2-drop-mask {
                z-index: 15990 !important;
            }

            .select2-drop-active {
                z-index: 15995 !important;
            }

            .staff {
                margin-top: 6px;
            }
            .nationality {
                margin-right: 15px;
            }
            div.dataTables_filter label input{
                width: 100%;
            }

        </style>
    </head>
    <body>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>课程信息管理</h5>
                            <button class="btn btn-primary" id="addBtn">新增</button>
                        </div>
                        <div class="row s-row">
                            <div class="col-sm-12">
                                <div class="price-div">
                                    <form class="form-horizontal">
                                        <div class="form-group cyf-form-group">
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left" class="col-sm-4 control-label cvbnm">学院: </label>
                                                <select class="form-control col-sm-6" id="college_id" name="college_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <volist name="college_info" id="college_info">
                                                        <option value="{$college_info.sch_id}">{$college_info.sch_name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left; margin-right: 13px" class="col-sm-4 control-label cvbnm">系: </label>
                                                <select class="form-control col-sm-" id="department_id" name="department_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <volist name="department_info" id="department_info">
                                                        <option value="{$department_info.dept_id}" pid="{$department_info.sch_id}" class="p_department_id" style="display: none;">{$department_info.dept_name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <table class="table table-striped table-bordered table-hover dataTables-example">
                                <thead>
	                                <tr>
	                                    <th width="16.66%">课程编号</th>
	                                    <th width="16.66%">课程名称</th>
	                                    <th width="16.66%">课程类型</th>
	                                    <th width="16.66%">学分</th>
	                                    <th width="16.66%">学时</th>
	                                    <th width="16.66%">操作</th>
	                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Modal 编辑专业-->
        <div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel"></h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" id="form_add">
                            <div class="form-group">
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cvbnm nationality cyf-label">所属学院</label>
                                    <select class="form-control poiu" id="sch_select" name="sch_select">
                                        <option value="0">请选择</option>
                                        <volist name="par_college" id="vo">
                                            <option value="{$vo.sch_id}">{$vo.sch_name}</option>
                                        </volist>
                                    </select>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cvbnm nationality cyf-label">所属系部</label>
                                    <select class="form-control poiu" id="dept_select" name="dept_select">
                                        <option value="0">请选择</option>
                                        <volist name="par_department" id="par_department">
                                            <option value="{$par_department.dept_id}" pid="{$par_department.sch_id}" class="p_department_id" style="display: none;">{$par_department.dept_name}</option>
                                        </volist>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label">课程编号</label>
                                    <div class="col-sm-9" style="padding-right:5px ">
                                        <input type="text" id="course_id" name="course_id" class="form-control  removeData">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label">课程名称</label>
                                    <div class="col-sm-9" style="padding-right:5px ">
                                        <input type="text" id="input_name" name="course_name" class="form-control removeData">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6">
                                    <div class="row">
                                        <div class="col-sm-12" style="margin-top: 10px;margin-bottom: 10px">
                                            <label class="col-sm-3 control-label cyf-label">课程学分</label>
                                            <div class="col-sm-9" style="padding-right:5px ">
                                                <input type="text" id="input_credit" name="input_credit" class="form-control removeData">
                                            </div>
                                         </div>
                                        <div class="col-sm-12" style="margin-top: 10px;margin-bottom: 10px">
                                            <label class="col-sm-3 control-label cyf-label">课程学时</label>
                                            <div class="col-sm-9" style="padding-right:5px ">
                                                <input type="text" id="input_hour" name="input_hour" class="form-control removeData">
                                            </div>
                                        </div>
                                        <div class="col-sm-12" style="margin-top: 10px;margin-bottom: 10px">
                                            <label class="col-sm-3 control-label cyf-label">创建时间</label>
                                            <div class="col-sm-9" style="padding-right:5px ">
                                                <input type="text" id="create_time" name="create_time" class="laydate-icon form-control layer-date removeData">
                                            </div>
                                        </div>
                                        <div class="col-sm-12" style="margin-top: 10px;margin-bottom: 10px">
                                            <label class="col-sm-3 control-label cvbnm nationality cyf-label">课程类型</label>
                                            <select class="form-control poiu" id="type_select" name="type_select">
                                                <option value="0">请选择</option>
                                                <volist name="tctype_info" id="tctype_info">
                                                    <option value="{$tctype_info.type_id}"  class="p_department_id"">{$tctype_info.type_name}</option>
                                                </volist>
                                            </select>
                                        </div>
                                        <div class="col-sm-12" style="margin-top: 10px;margin-bottom: 10px">
                                            <label class="col-sm-3 control-label cvbnm nationality cyf-label">实验语言</label>
                                            <select class="form-control poiu" id="language_select" name="language_select">
                                                <option value="0">请选择</option>
                                                <volist name="language_info" id="language_info">
                                                    <option value="{$language_info.language_id}"  class="p_department_id"">{$language_info.language_name}</option>
                                                </volist>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label" >课程图标: </label>
                                    <div class="col-sm-9" style="padding-right: 5px">
                                        <input class="file form-control  cyf-inpput" name="upload_image" id="upload_image" type="file" data-show-caption="true" multiple accept="application/*" />
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label">作业权重</label>
                                    <div class="col-sm-9" style="padding-right:5px ">
                                        <input type="text" id="input_hour" name="input_hour" class="form-control removeData">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label">测试权重</label>
                                    <div class="col-sm-9" style="padding-right:5px ">
                                        <input type="text" id="input_hour" name="input_hour" class="form-control removeData">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label">论坛权重</label>
                                    <div class="col-sm-9" style="padding-right:5px ">
                                        <input type="text" id="input_hour" name="input_hour" class="form-control removeData">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label">练习权重</label>
                                    <div class="col-sm-9" style="padding-right:5px ">
                                        <input type="text" id="input_hour" name="input_hour" class="form-control removeData">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label">平时权重</label>
                                    <div class="col-sm-9" style="padding-right:5px ">
                                        <input type="text" id="input_hour" name="input_hour" class="form-control removeData">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label">期中权重</label>
                                    <div class="col-sm-9" style="padding-right:5px ">
                                        <input type="text" id="input_hour" name="input_hour" class="form-control removeData">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label cyf-label">期末权重</label>
                                    <div class="col-sm-9" style="padding-right:5px ">
                                        <input type="text" id="input_hour" name="input_hour" class="form-control removeData">
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="add_btn">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <include file='Layout:ins_js' />
        <script src="__JS__/plugins/layer/laydate/laydate.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                sTable = $(".table").DataTable({
                    "fnServerParams": function(aoData) {
                        aoData.push({
                            'name': 'dept_id',
                            'value': $('select#department_id option:selected').val(),
                        });
                    },
                    "bAutoWidth":false,
                    "oLanguage": {
                        "sLengthMenu": "每页 _MENU_ "
                    },
                    "sAjaxSource": "__URL__/courseinfo_ShowDatatables", //调用php后台接口方法地址
                    "aoColumns": [{
                        'data': 'id'
                    }, {
                        'data': 'name'
                    },{
                        'data': 'type'
                    },{
                        'data': 'credit'
                    },{
                        'data': 'hour'
                    },{
                        "data": null,
                        orderable: false,
                        render: function(data, type, row, meta) {
                            return '<a type="button" class="btn btn-success" href="#" onclick=editFromID(this) >编辑</a>|<a type="button" class="btn btn-danger" href="#" onclick=delFromID(this) >删除</a>'
                        }
                    }]
                });

                <!--------    初始化select2     !-------->
                //学院
                $("#sch_select").select2({
                    width: '170px',
                    dropdownParent: $("#Modal")
                });
                //系部
                $("#dept_select").select2({
                    width: '170px',
                    dropdownParent: $("#Modal")
                });
                $('#type_select').select2({
                    width: '170px',
                    dropdownParent: $('#Modal')
                });
                $('#language_select').select2({
                    width: '170px',
                    dropdownParent: $('#Modal')
                });

                //外部js调用
                laydate({
                    elem: '#create_time', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                    event: 'focus' //响应事件。如果没有传入event，则按照默认的click
                });


            });
            //查询按钮
            $("select#college_id").change(function() {
                //console.log( $('select#college_id option:selected').val());
                var p_id = $("#college_id").val();
                $("#department_id option").hide();
                $('#department_id').val('0');
                $('option[pid=' + p_id + ']').show();
                sTable.ajax.reload();
            });
            $("select#department_id").change(function() {
                //console.log( $('select#college_id option:selected').val());
                sTable.ajax.reload();
            });
            <!--------------   上传文件                !----------------->
            // 上传
            $("#upload_image").fileinput({
                language: 'zh', //设置语言
                uploadUrl: "__URL__/Upload", //上传的地址
                allowedFileExtensions: ['jpg', 'gif', 'png', 'jpeg'], //接收的文件后缀
                autoReplace: true,
                browseLabel: '上传文件',
                uploadAsync: false, //默认异步上传
                showUpload: false, //是否显示上传按钮
                showRemove: false, //显示移除按钮
                showPreview: true, //是否显示预览
                showCaption: false, //是否显示标题
                browseClass: "btn btn-primary", //按钮样式
                dropZoneEnabled: true, //是否显示拖拽区域
                maxFileSize: 3000, //单位为kb，如果为0表示不限制文件大小
                maxFileCount: 1, //表示允许同时上传的最大文件个数
                enctype: 'multipart/form-data',
                previewClass: 'previewPanel',
                //	initialPreview: [

                //	"<img src='__ROOT__/Upload/Upload_brands/" + urlImg + " ' class='file-preview-image' />",

                //],
                previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",

            });
            //同步上传成功结果处理
            $('#upload_image').on('filebatchuploadsuccess', function(event, data, previewId, index) {
                alert(data.response.info);
            });
            <!--------------   新增模态框相关     !----------------->
            //新增模态框弹出
            $("#addBtn").on('click', function() {
                $("#Modal").modal();
            });
            //新增模态框 - 学院 选择事件-
            $('select#sd_boss_add').change(function () {

            });





            //编辑模态框弹出
            function editFromID(obj) {
        //				var grandobj = $(obj).parent().parent();
        //				var rowdata = sTable.row(grandobj).data();
        //				$("#unit_names").val(rowdata.unit_name);
        //				$("#unit_id").val(rowdata.unit_id);
        //				Patientia = rowdata.language_id;
        //				$("#languagetype").val(Patientia).trigger("change");
        //				$('.wrapper').removeClass('animated');
                $("#EditNoModal").modal();
            }


            //销毁模态框
            $(".modal").on("hidden.bs.modal", function() {
                $('.removeData').val('');
                $(".wrapper").addClass('animated');
            });
        </script>
    </body>
</html>